package cn.fl.carloan.service.impl;

import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.fl.carloan.service.IOdrClueRemService;
import cn.fl.carloan.transform.OdrClueRemVOTransform;
import cn.fl.carloan.vo.OdrClueRemVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import fl.carloan.facade.carloan.api.IOdrClueRemApiService;
import fl.carloan.facade.carloan.condition.OdrClueRemQC;
import fl.carloan.facade.carloan.dto.OdrClueRemDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OdrClueRemServiceImpl implements IOdrClueRemService {

    private Logger LOG = LoggerFactory.getLogger(OdrClueRemServiceImpl.class);


    @Autowired
    private IOdrClueRemApiService odrClueRemApiService;

    @Override
    public boolean add(OdrClueRemVO odrClueRemVO) {
        OdrClueRemDTO odrClueRemDTO = OdrClueRemVOTransform.toDTO(odrClueRemVO);
        boolean b = false;
        try {

            b = odrClueRemApiService.addRem(odrClueRemDTO);
            BaseLogUtils.info(LOG, "OdrClueRemServiceImpl.addRem", "添加备注成功", CurrentThreadContext.getCurrentUserName());
        } catch (Exception e) {
            e.printStackTrace();
            BaseLogUtils.info(LOG, "OdrClueRemServiceImpl.addRem", "添加备注失败", CurrentThreadContext.getCurrentUserName());
            throw new BaseException("添加失败");
        }

        // odrClueApiService.addRem();

        return b;
    }

    @Override
    public List<OdrClueRemVO> selectRemListByClueId(String id) {
        BaseLogUtils.info(LOG, "selectRemListByClueId", "查询备注列表 参数备注id："+id, CurrentThreadContext.getCurrentUserName());
        OdrClueRemQC condition = new OdrClueRemQC();
        condition.setClueId(Long.valueOf(id));
        List<OdrClueRemDTO> odrClueRemDTOS = odrClueRemApiService.selectRemList(condition);
        List<OdrClueRemVO> odrClueRemVOS = OdrClueRemVOTransform.toVOList(odrClueRemDTOS);
        return odrClueRemVOS;
    }
}
